﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DBUtil.FastEntity.Annotations
{
    /// <summary>
    /// 表示一个扩展列映射
    /// </summary>
    [AttributeUsage(AttributeTargets.Property)]
    public class MapExtendColumnAttribute : Attribute
    {
        /// <summary>
        /// 关联表的映射类型,必填
        /// </summary>
        public Type ExtendTableType { get; set; }

        /// <summary>
        /// 从关联表映射类型的哪个属性中提取值,必填
        /// </summary>
        public string ExtendTableFetchProp { get; set; }

        /// <summary>
        /// 从当前类型的哪个属性值中找相等关系,必填
        /// </summary>
        public string CompareOwnProp { get; set; }

        /// <summary>
        /// 从关联表映射类型的哪个属性中找相等关系,默认主键
        /// </summary>
        public string ExtendTableCompareProp { get; set; }

        /// <summary>
        /// 抓取扩展表列值的策略
        /// </summary>
        public FetchStrategy FetchStrategy { get; set; }
    }

    /// <summary>
    /// 从扩展表抓取列值的策略
    /// </summary>
    public enum FetchStrategy
    {
        /// <summary>
        /// 直接抓取
        /// </summary>
        Direct,
        /// <summary>
        /// 抓取总数量
        /// </summary>
        Count,
        /// <summary>
        /// 抓取最大值
        /// </summary>
        Max,
        /// <summary>
        /// 抓取最小值
        /// </summary>
        Min,
        /// <summary>
        /// 抓取平均值
        /// </summary>
        Avg,
        /// <summary>
        /// 抓取合计
        /// </summary>
        Sum
    }
}
